//
//  GGTTeamBuyTableViewCell.m
//  GGT
//
//  Created by 空空空 on 14/10/28.
//  Copyright (c) 2014年 GGT. All rights reserved.
//

#import "GGTTeamBuyTableViewCell.h"
//#import "GGTTeamBuyModel.h"
#import "UIImageView+WebCache.h"
//#import "GGTDeleteLabel.h"
@implementation GGTTeamBuyTableViewCell
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        // Initialization code
        //初始化
        self.imgView = [[UIImageView alloc]init];
        [self.contentView addSubview:self.imgView];
        //self.imgView.backgroundColor = [UIColor redColor];
        self.titleLabel = [[UILabel alloc]init];
        [self.contentView addSubview:self.titleLabel];
        //self.titleLabel.backgroundColor = [UIColor grayColor];
        self.descriptLabel = [[UILabel alloc]init];
        [self.contentView addSubview:self.descriptLabel];
        //self.descriptLabel.backgroundColor = [UIColor grayColor];
        self.currentLabel = [[UILabel alloc]init];
        [self.contentView addSubview:self.currentLabel];
        self.listLabel = [[GGTDeleteLabel alloc]init];
        [self.contentView addSubview:self.listLabel];
        self.distanceLabel = [[UILabel alloc]init];
        [self.contentView addSubview:self.distanceLabel];
    }
        return self;
}
- (void)layoutSubviews
{
    [super layoutSubviews];
    
    self.titleLabel.text = self.GGTTeamBuy.title;
    self.descriptLabel.text = self.GGTTeamBuy.descript;
    UIFont *tfont3 = [UIFont fontWithName:@".HelveticaNeueInterface-Regular" size:13.00];
    self.descriptLabel.font = tfont3;
    self.descriptLabel.textColor = [UIColor grayColor];
    self.descriptLabel.numberOfLines = 0;

    self.descriptLabel.textAlignment = NSTextAlignmentLeft;
    self.currentLabel.text = [NSString stringWithFormat:@"￥%@", self.GGTTeamBuy.current_price];
    UIFont *tfont = [UIFont fontWithName:@".HelveticaNeueInterface-Regular" size:22.00];
    self.currentLabel.font = tfont;
    self.currentLabel.textColor = [UIColor orangeColor];
    self.listLabel.text = [NSString stringWithFormat:@"￥%@", self.GGTTeamBuy.list_price];

    
//加载视图
    [self.imgView setImageWithURL:[NSURL URLWithString:self.GGTTeamBuy.image]];
    [self.imgView setImageWithURL:[NSURL URLWithString:self.GGTTeamBuy.image] placeholderImage:[UIImage imageNamed:@"hold.png"]];
    self.imgView.frame = CGRectMake(10, 10, self.contentView.frame.size.width / 3, 100);
    self.titleLabel.frame = CGRectMake(self.contentView.frame.size.width / 3 + 20,0, self.contentView.frame.size.width / 3 * 2 - 50, self.contentView.frame.size.width / 9);
    self.descriptLabel.frame = CGRectMake(self.contentView.frame.size.width / 3 + 20, self.contentView.frame.size.height / 4, self.contentView.frame.size.width / 3 * 2 - 20, self.contentView.frame.size.width / 5);
    self.currentLabel.frame = CGRectMake(self.contentView.frame.size.width / 3 + 20, self.contentView.frame.size.height / 4 * 3, self.contentView.frame.size.width / 4, self.contentView.frame.size.width / 11);
    //self.currentLabel.backgroundColor = [UIColor grayColor];
    //self.listLabel.backgroundColor = [UIColor grayColor];
    UIFont *tfont1 = [UIFont fontWithName:@".HelveticaNeueInterface-Regular" size:14.00];
    self.listLabel.font = tfont1;
    if (self.currentLabel.text.length > 3) {
        self.listLabel.frame = CGRectMake(self.contentView.frame.size.width / 3 + self.contentView.frame.size.width / 4 + 7, self.contentView.frame.size.height / 4 * 3 + 5, self.contentView.frame.size.width / 5, self.contentView.frame.size.width / 11);
    } else {
        self.listLabel.frame = CGRectMake(self.contentView.frame.size.width / 3 + self.contentView.frame.size.width / 5 + 10, self.contentView.frame.size.height / 4 * 3 + 5, self.contentView.frame.size.width / 5, self.contentView.frame.size.width / 11);
    }
    
    self.distanceLabel.frame = CGRectMake(280, 20, 40, 30);
}
- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}
- (void)dealloc
{
    [_currentLabel release];
    [_listLabel release];
    [_titleLabel release];
    [_imgView release];
    [_descriptLabel release];
    [_distanceLabel release];
    [super dealloc];
}
@end
